package com.gitee.chenyaohua.utils;



public enum  ColumnType {


    VARCHAR("varchar","String"),
    INT("int","int"),
    LONGTEXT("longtext","String"),
    BIGINT("bigint","Long"),
    ENUM("enum","enum"),
    TEXT("text","String"),
    MEDIUMTEXT("mediumtext","String"),
    JSON("json","JSON"),
    DATETIME("datetime","Date"),
    SET("set","List"),
    TIMESTAMP("timestamp","Date"),
    DATE("date","Date"),
    TIME("time","Date"),
    YEAR("year","Date"),
    CHAR("char","String"),
    BINARY("binary","Byte[]"),
    VARBINARY("varbinary","Byte[]"),
    TINYINT("tinyint","Short"),
    BLOB("blob","Byte[]"),
    DOUBLE("double","Double"),
    DECIMAL("decimal","BigDecimal"),
    FLOAT("float","Float");



    private String jdbcType;


    private String javaType;

    ColumnType(String jdbcType, String javaType) {
        this.jdbcType = jdbcType;
        this.javaType = javaType;
    }


    public String getJdbcType() {
        return jdbcType;
    }

    public String getJavaType() {
        return javaType;
    }

    public static ColumnType parse(String jdbcType){

        ColumnType[] values = ColumnType.values();
        for (int i = 0; i < values.length; i++) {
            if (values[i].getJdbcType().equals(jdbcType)) {
                return values[i];
            }
        }

        throw new RuntimeException("未知数据类型");
    }

}
